package riki.org.com.handle
{
	import mx.controls.dataGridClasses.DataGridColumn;
	
	import riki.org.com.command.NcSend;
	import riki.org.com.date.OnlineApps;
	import riki.org.com.model.ModelLocator;
	
	public class NetAppListHandle
	{
		public static function OnChangeSelect():void
		{
			var model	:ModelLocator	= ModelLocator.getInstance();
			var tObj	:Object;
			var	i		:int			=	0;
			var	p		:String			=	"";
			
			/*
			trace("List:"+model.vObj.ServerAppListCom.selectedItem)
			for(var p:String in model.vObj.ServerAppListCom.selectedItem)
			{
				trace(p,model.vObj.ServerAppListCom.selectedItem[p])
			}
			*/
			
			var appName:String	=	model.vObj.ServerAppListCom.selectedItem.data;
			model.vObj.MainApp.GameName.label	=	appName;
			
			var	tempApp:OnlineApps	=	model.sDataBase.getApplicationInfo(appName);
			//if(!tempApp.isHaveDate)
			//{
				NcSend.getServerApplicationInfo(appName);
				model.sDataBase.getApplicationInfo(appName).isHaveDate	=	true;
			/*
			}
			else
			{
				model.vObj.MainApp.OnlinesPlayer.label	=	tempApp.PlayerCount.toString();
				model.vObj.MainApp.OnlinesRoom.label	=	tempApp.RoomCount.toString();
				model.vObj.MainApp.downloads1.label		=	tempApp.DownloadCountOfToday.toString();
				model.vObj.MainApp.downloads2.label		=	tempApp.DownloadCountOfHistory.toString();
				model.vObj.MainApp.used1.label			=	tempApp.PlayCountOfToday.toString();
				model.vObj.MainApp.used2.label			=	tempApp.PlayCountOfHistory.toString();
				
				var tempcolumn:DataGridColumn;
				
				if(!(tempApp.PlayeList.length<1))
				{
					tObj	=	tempApp.PlayeList.getItemAt(0);
				}
				model.vObj.MainApp.GameUserList.columns			=	new	Array();
				for(p	in	tObj)
				{
					trace(p)
					tempcolumn				= new DataGridColumn();
					tempcolumn.headerText	=	p;
					tempcolumn.dataField	=	p;
					model.vObj.MainApp.GameUserList.columns	= model.vObj.MainApp.GameUserList.columns.concat(tempcolumn);
				}
				
				if(!(tempApp.RoomList.length<1))
				{
					tObj	=	tempApp.RoomList.getItemAt(0);
				}				
				model.vObj.MainApp.GameRoomList.columns			=	new	Array();
				for(p	in	tObj)
				{
					trace(p)
					tempcolumn				= new DataGridColumn();
					tempcolumn.headerText	=	p;
					tempcolumn.dataField	=	p;
					model.vObj.MainApp.GameRoomList.columns	= model.vObj.MainApp.GameRoomList.columns.concat(tempcolumn);
				}
				
				model.vObj.MainApp.GameUserList.horizontalScrollPolicy	=	"on"
				model.vObj.MainApp.GameRoomList.horizontalScrollPolicy	=	"on"
				
				model.vObj.MainApp.GameUserList.dataProvider	=	tempApp.PlayeList;
				model.vObj.MainApp.GameRoomList.dataProvider	=	tempApp.RoomList;
			}*/
		}
	}
}